//	AUTHOR:			ENRICO CANTONI
//	CREATED:		SEPTEMBER 19, 2017
//	MODIFIED: 		NOVEMBER 7, 2022
//	DESCRIPTION:	This is the master analysis file.
//					All analysis files should be run through this program.
//					To run this file, change the global "root" on line 20
//					to reflect the correct location on the user's machine.
//					"Root" should refer to the directory of the main folder
//					containing the "Code", "Data", and "Output" subfolders.


// Set Stata version
version 16.1

// Clear memory
clear all
set more off

// Set global values
global root C:/Users/canto/Dropbox/vote_family/Replication
do ${root}/Code/globals.do
cd ${root}

// Code files
local code_descriptive			"analysis_descriptive.do"
local code_graphs_descriptive 	"analysis_graphs_descriptive.do"
local code_graphs_event 		"analysis_graphs_event.do"
local code_graphs_kids	 		"analysis_graphs_kids.do"
local code_tables_summary 		"analysis_tables_summary.do"
local code_tables_bologna		"analysis_tables_bologna.do"

********************************************************************************
********************************************************************************

// Wipe scratch directory
dir_clear, dir(${data_scratch}) ext(dta)

// Switches: these control which parts of the data cleaning code you will re-run
#delimit ;
local switches_all
	descriptive				// In-text descriptive figures
	graphs_descriptive		// Figures 1, 2, A1, A2, and A4
	graphs_event			// Figures 3, 5, A5, A6, A7, A8, and A9
	graphs_kids				// Figure 4
	tables_summary			// Tables 1, A1, and A2
	tables_bologna			// Tables 2, 3, A3, A4, A5, A6, and A7
;
#delimit cr

	/* descriptive stats	*/	local switch_descriptive		= 1
	/* descriptive graphs 	*/	local switch_graphs_descriptive = 1
	/* event-study graphs 	*/ 	local switch_graphs_event 		= 1
	/* kids' age dummies 	*/	local switch_graphs_kids 		= 1
	/* summary stats 		*/ 	local switch_tables_summary 	= 1
	/* turnout tables		*/	local switch_tables_bologna		= 1

********************************************************************************
********************************************************************************

// Start timer
timer on 1

foreach switch of local switches_all {
	if `switch_`switch'' {
		cd ${code_analysis}
		do `code_`switch''
	}
}

// End timer
timer off 1
timer list 1
